package structure.timewheel;

/**
 * Created by Anur IjuoKaruKas on 2018/10/16
 *
 * 双向链表 有一个就能找到整个环
 * 这样bucket只要存一个TimedTask
 * 需要延迟执行的任务，放在槽 {@link Bucket} 里面
 */
public class TimedTask {
    

    /** 过期时间戳 */
    private final long expireTimestamp;

    /** 任务 */
    private final Runnable task;

    protected Bucket bucket;

    protected TimedTask next;

    protected TimedTask pre;
    

    public TimedTask(long delayMs, Runnable task) {
        this.task = task;
        this.expireTimestamp = System.currentTimeMillis() + delayMs;
    }
    

    public Runnable getTask() {
        return task;
    }
    

    public long getExpireTimestamp() {
        return expireTimestamp;
    }
    
}
